# Cookies_RepeatedCode.py
#
# Description: Draws a chocolate chip cookie with our turtle.
#
# Anne Lavergne
# Date: Feb. 26 2024


# Import the turtle library
import turtle

# Function to draw a chocolate chip cookie
def drawCookie(aTurtle,aX,aY,aRadius):
    """Draw a chocolate chip cookie."""
    
    # Draw the contour of the cookie
    aTurtle.penup()
    aTurtle.goto(aX,aY)
    aTurtle.pendown()
    aTurtle.circle(aRadius)
    aTurtle.penup()

    # Compute the centre (x,y) of the cookie 
    centreX = aX        
    centreY = aY+radius

    # Draw a chocolate chip in the middle of the cookie
    aTurtle.goto(centreX,centreY)
    aTurtle.color('saddlebrown')
    aTurtle.stamp()

    # Draw a chocolate chip in the top left area of the cookie
    aTurtle.goto(centreX-10,centreY+10)
    aTurtle.color('pink')
    aTurtle.stamp()

    # Draw a chocolate chip in the bottom left area of the cookie
    aTurtle.goto(centreX-15,centreY-10)
    aTurtle.color('yellow')
    aTurtle.stamp()

    # Draw a chocolate chip in the bottom right area of the cookie
    aTurtle.goto(centreX+20,centreY-15)
    aTurtle.color('green')
    aTurtle.stamp()

    # Draw a chocolate chip in the top right area of the cookie
    aTurtle.goto(centreX+12,centreY+15)
    aTurtle.color('red')
    aTurtle.stamp()

    return


# Creates a graphics window - canvas
canvas = turtle.Screen()

# Create a turtle named tt
tt = turtle.Turtle()

# Set radius
radius = 30

# Draw cookies
for location in ((-140,-120), (100,75), (0,0), (-68,100)):
    drawCookie(tt, location[0], location[1], radius)
    tt.color('black')

# Click on the canvas to exit
canvas.exitonclick()